<!DOCTYPE html>
<html lang="en" dir="ltr" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<div class="modal modal-blur fade" id="modal-report" tabindex="-1" role="dialog" aria-hidden="true">
    <div class="modal-dialog modal-lg" role="document" th:fragment="column">
        <div class="modal-content">
            <div class="modal-header">
                <h5 class="modal-title" id="modalTitle">
                    <div class="mb-3 float-right">
                        <div class="input-icon">
                            <input type="text" class="form-control form-control-rounded" placeholder="请输入关键字…">
                            <span class="input-icon-addon">
                                  <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="icon"><circle cx="11" cy="11" r="8"></circle><line x1="21" y1="21" x2="16.65" y2="16.65"></line></svg>
                                </span>
                        </div>
                        <div class="alert alert-success col-login float-right" role="alert" style="position:absolute;zIndex:-1;right: 50px;display: none" id="alert-success">
                            修改成功
                        </div>
                        <div class="alert alert-error col-login float-right" style="position:absolute;zIndex:-1;right: 50px;display: none" role="alert"  id="alert-fail">
                            修改失败，请稍后重试
                        </div>
                    </div>
                </h5>
                <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                </button>
            </div>
            <div class="modal-body">
                <div class="table-responsive">
                    <table class="table card-table table-hover text-nowrap">
                        <thead>
                        <tr>
                            <th class="w-1">ID</th>
                            <th>标题</th>
                            <th>简介</th>
                            <th>操作</th>
                        </tr>
                        </thead>
                        <tbody>
                        <tr th:each="column : ${unAddColumn}">
                            <td>
                                <span class="text-muted" th:text="${column.id}">001401</span>
                            </td>
                            <td>
                                <a href="javascript:void(0)" class="text-inherit" th:text="${column.name}">设计模式</a>
                            </td>
                            <td>
                                <a href="javascript:void(0)" class="text-inherit" th:text="${column.summary}">设计模式</a>
                            </td>
                            <td>
                                <button class="btn btn-secondary btn-space btn-sm" onclick="addColumn(this)" th:attr="articleId=${articleId},columnId=${column.id}">添加</button>
                            </td>
                        </tr>
                        </tbody>
                    </table>
                </div>
            </div>
        </div>
        <script>
            function addColumn(ele) {
                let articleId = $(ele).attr("articleId");
                let columnId = $(ele).attr("columnId");
                $.ajax({
                    type: "post",
                    url: "/admin/column/item",
                    data: {"columnId": columnId, "articleId": articleId},
                    success: function (data) {
                        if (data.code == 200) {
                            alert("添加成功");
                            $("#modal-report").modal('hide');
                        }
                    },
                    error: function (data) {
                    }
                })
            }
        </script>
    </div>
</div>
</body>
</html>